import time

from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Edge()
driver.get("http://www.baidu.com")
time.sleep(2)

# # 二次定位
# # 定位百度左上角的div
# div = driver.find_element(By.ID,"s-top-left")
# aes = div.find_elements(By.TAG_NAME,"a")
# for i in aes:
#     print(i.text)
#
# # 鼠标移动
# # 创建动作链对象
# ab = ActionChains(driver)
# # 获取拖动的标签
# a = driver.find_element(By.PARTIAL_LINK_TEXT,"北京")
# # 获取文本编辑标签
# b = driver.find_element(By.ID,"chat-textarea")
# # 动作链对象进行拖动动作，并且执行
# ab.drag_and_drop(a,b).perform()
# # 执行回车
# ab.send_keys(Keys.ENTER).perform()
# time.sleep(2)

# 键盘操作
b = driver.find_element(By.ID,"chat-textarea")
b.send_keys("javascript")

# 获取发送内容 键盘全选
b.send_keys(Keys.CONTROL,"A")

# 复制
b.send_keys(Keys.CONTROL,"C")

# 粘贴
b.send_keys(Keys.CONTROL,"V")

b.send_keys(Keys.ENTER)

time.sleep(100)
